import 'package:distribution_mall_flutter/constant/cf_constant.dart';
import 'package:distribution_mall_flutter/generated/l10n.dart';
import 'package:distribution_mall_flutter/pages/goods/product_details/widgets/price.dart';
import 'package:distribution_mall_flutter/utils/image_loader.dart';
import 'package:distribution_mall_flutter/widgets/counter_input.dart';
import 'package:distribution_mall_flutter/widgets/ink_well_view.dart';
import 'package:distribution_mall_flutter/widgets/modal_button.dart';
import 'package:flutter/material.dart';

class ModalSpec extends StatelessWidget {
  final double maxHeightScale;
  const ModalSpec({super.key, this.maxHeightScale = 0.85});

  Widget otherTitleRender() {
    return const Column(
      children: [
        Row(
          children: [Price()],
        ),
        Divider(
          color: Color.fromRGBO(221, 221, 221, 0.5),
        ),
        SizedBox(
          height: 13,
        )
      ],
    );
  }

  Widget specRender() {
    return Padding(
      padding: const EdgeInsets.only(top: EdgeConstant.edge15),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Expanded(
              child: Row(
            children: [
              ImageLoader.imageNet('', width: 37, height: 37, radius: 5),
              const Expanded(
                  child: Padding(
                      padding: EdgeInsets.only(left: EdgeConstant.edge10),
                      child: Text(
                        '123123',
                        maxLines: 2,
                        overflow: TextOverflow.ellipsis,
                        style: TextStyle(
                            fontSize: FontConstant.f13,
                            color: Colors.black,
                            fontWeight: FontWeight.normal,
                            decoration: TextDecoration.none),
                      )))
            ],
          )),
          // const CounterInputGroup()
        ],
      ),
    );
  }

  List<Widget> childrenRender() {
    return [
      Text(
        S.current.specifcation,
        style: const TextStyle(
            fontSize: FontConstant.f17,
            color: Colors.black,
            fontWeight: FontWeight.normal,
            decoration: TextDecoration.none),
      ),
      specRender()
    ];
  }

  Widget footerRender() {
    return Column(
      children: [
        const Divider(
          color: Color.fromRGBO(221, 221, 221, 0.5),
        ),
        Padding(
          padding: const EdgeInsets.symmetric(vertical: EdgeConstant.edge10),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              const Text(
                'Selected 2 pieces',
                style: TextStyle(
                    fontSize: FontConstant.f11,
                    color: ColorConstant.grey136,
                    decoration: TextDecoration.none),
              ),
              RichText(
                text: const TextSpan(
                    text: 'Amount to:',
                    style: TextStyle(
                        fontSize: FontConstant.f13, color: Colors.black),
                    children: [
                      TextSpan(
                          text: '123123',
                          style: TextStyle(
                              fontWeight: FontWeight.w600,
                              fontSize: FontConstant.f20,
                              color: Color.fromRGBO(227, 50, 11, 1)))
                    ]),
              )
            ],
          ),
        ),
        EPInkWellView(
            child: Container(
              width: 331,
              height: 37,
              alignment: Alignment.center,
              decoration: const BoxDecoration(
                  borderRadius: BorderRadius.all(Radius.circular(20.5)),
                  boxShadow: [
                    BoxShadow(
                        color: Color.fromRGBO(255, 80, 0, 0.3),
                        blurRadius: 4.7,
                        offset: Offset(0, 2.8))
                  ],
                  gradient: LinearGradient(
                    begin: Alignment.centerRight,
                    end: Alignment.centerLeft,
                    colors: [
                      Color.fromRGBO(255, 80, 0, 1),
                      Color.fromRGBO(255, 144, 0, 1)
                    ],
                  )),
              child: Text(
                S.current.addCart,
                style: const TextStyle(
                    fontSize: FontConstant.f15,
                    color: Colors.white,
                    fontWeight: FontWeight.normal,
                    decoration: TextDecoration.none),
              ),
            ),
            onPressed: () {})
      ],
    );
  }

  @override
  Widget build(BuildContext context) {
    return EPModalButton(
      titleBorder: null,
      titleMargin: const EdgeInsets.only(bottom: 0),
      title: '',
      maxHeightScale: maxHeightScale,
      otherTitle: otherTitleRender(),
      footerChild: footerRender(),
      children: childrenRender(),
    );
  }
}
